package edu.hrbu.spring.dao.impl;

import edu.hrbu.spring.dao.AccountDao;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @author 徐登宇
 */
@Repository
public class AccountDaoImpl implements AccountDao {

    @Resource(name = "jdbcTemplate")
    JdbcTemplate jdbcTemplate;

    @Override
    public int selectById(int id) {
        String sql="select acc_balance from account where acc_id=?";
        return jdbcTemplate.queryForObject(sql,int.class, id);
    }

    @Override
    public int update(int id, int balance) {
        String sql="update account set acc_balance=? where acc_id=?";
        return jdbcTemplate.update(sql, balance, id);
    }
}
